class Friend < ActiveRecord::Base
  has_many :friend

  #checking for basic prescence for both attributes here.
  validates :user_id, :presence => true
  validates :friend_id, :presence => true
  
  #checking that user id and friend id are valid users in the users table.
  validate :user_check_id
     def user_check_id
          if((friend == User.find_by(user_id)) == nil)
               errors.add(:user_id, "This is an invalid user id.")
          end 
    end

 validate :friend_check_id
     def friend_check_id
          if((friend == User.find_by(friend_id)) == nil)
               errors.add(:friend_id, "This is an invalid id for a friend.")
          end     
     end

end
